package com.edgclub.edg.adapter;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.AnimationDrawable;
import android.media.MediaPlayer;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.ScaleAnimation;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.edgclub.edg.R;
import com.edgclub.edg.activity.GroupDetailsActivity;
import com.edgclub.edg.activity.GzTopicDetailActivity;
import com.edgclub.edg.activity.GzWebViewActivity;
import com.edgclub.edg.activity.UserInfoOtherActivity;
import com.edgclub.edg.adapter.adapteruitls.GzBaseAdapter;
import com.edgclub.edg.adapter.adapteruitls.MyItemClickListener;
import com.edgclub.edg.adapter.adapteruitls.MyItemLongClickListener;
import com.edgclub.edg.adapter.adapteruitls.RViewHolder;
import com.edgclub.edg.constant.BBConstant;
import com.edgclub.edg.event.BroadCastEvent;
import com.edgclub.edg.event.EventBus;
import com.edgclub.edg.model.PostsAlbum;
import com.edgclub.edg.model.Topic;
import com.edgclub.edg.uc.UnableScrollGridView;
import com.edgclub.edg.utils.GlideUtil.GlideUtils;
import com.edgclub.edg.utils.util.DateUtils;
import com.edgclub.edg.utils.util.DensityUtils;
import com.edgclub.edg.utils.util.MediaPlayerUtil;
import com.rockerhieu.emojicon.EmojiconTextView1;
import com.squareup.otto.ThreadEnforcer;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 */
public class BBAdapter extends GzBaseAdapter{
    private List<Topic> datas = null;
    private Context mContext;
    private GlideUtils glideUtils;
    private int maxHeight = 403; //最长图设置403dp


    //语音
    private MediaPlayerUtil mediaPlayerUtil;
    private AnimationDrawable voiceAnimation = null;
    private List<ImageView> voiceViewList;
    private AnimationSet set;
    private String playMsgId;

    private LikeClickListener likeClickListener;
    private cancleCollectionPostListener collectionPostListener;

    private ScaleAnimation scaleAnimation;
    private ScaleAnimation starScaleAnimation;
    private AlphaAnimation alphaAnimation;
    private AnimationSet starSet;
    private boolean isVisableDelet;


    public BBAdapter(Context context) {
        this.mContext = context;
        mediaPlayerUtil = new MediaPlayerUtil(mContext);
        voiceViewList = new ArrayList<ImageView>();
        glideUtils = new GlideUtils();

        set = new AnimationSet(true);
        AlphaAnimation alph1 = new AlphaAnimation(0.2f, 1);
        alph1.setDuration(600);
        AlphaAnimation alph2 = new AlphaAnimation(1f, 0.4f);
        alph2.setDuration(600);
        alph2.setStartOffset(600);
        set.addAnimation(alph1);
        set.addAnimation(alph2);
        set.setRepeatCount(500);
        set.setFillAfter(true);

        scaleAnimation = new ScaleAnimation(1.0f,
                2.0f, 1.0f, 2.0f, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        scaleAnimation.setDuration(400);

        //点赞星星动画
        starSet = new AnimationSet(true);
        starScaleAnimation = new ScaleAnimation(0.5f,1.5f,1.0f,1.5f,
                Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
        starScaleAnimation.setDuration(400);
        alphaAnimation = new AlphaAnimation(0,1);
        alphaAnimation.setDuration(400);
        starSet.addAnimation(starScaleAnimation);
        starSet.addAnimation(alphaAnimation);

    }

    public void setVisableDelet(boolean visableDelet) {
        isVisableDelet = visableDelet;
    }

    //创建新View，被LayoutManager所调用
    @Override
    public BBAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
        View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_bb,viewGroup,false);
        ViewHolder vh = new ViewHolder(view,mListener,mLongClickListener);
        return vh;
    }

    //将数据与界面进行绑定的操作
    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder viewHolder1, final int position) {
        final BBAdapter.ViewHolder viewHolder= (ViewHolder) viewHolder1;
        final Topic topic =datas.get(position);

        if("0".equals(topic.getState())&&isVisableDelet){
            viewHolder.topic_all_layout.setVisibility(View.GONE);
            viewHolder.ll_banner.setVisibility(View.GONE);
            viewHolder.unsee_layout.setVisibility(View.VISIBLE);
            viewHolder.topic_unsee_del.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if(null!=collectionPostListener){
                        collectionPostListener.cancleCollectionPost(position);
                    }
                }
            });
            if(null!=topic.getUser().getUserAuth()){

                if ("-1".equals(topic.getUser().getUserAuth().getType())){
                    viewHolder.isvip.setVisibility(View.GONE);
                }
                if("0".equals(topic.getUser().getUserAuth().getType())){
                    viewHolder.isvip.setVisibility(View.VISIBLE);
                    viewHolder.isvip.setImageResource(R.drawable.v_huan);
                }else if("1".equals(topic.getUser().getUserAuth().getType())){
                    viewHolder.isvip.setVisibility(View.VISIBLE);
                    viewHolder.isvip.setImageResource(R.drawable.v_lan);
                }
            }else{
                viewHolder.isvip.setVisibility(View.GONE);
            }
        }else if(topic.getPostsId().equals("0")){
            viewHolder.topic_all_layout.setVisibility(View.GONE);
            viewHolder.unsee_layout.setVisibility(View.GONE);
            viewHolder.ll_banner.setVisibility(View.VISIBLE);
            final ArrayList<PostsAlbum> albums = topic.getAlbums();
            if (albums != null && albums.size() > 0) {
                glideUtils.Glidde_loadImageBanner(mContext,albums.get(0).getThumbnail(),viewHolder.imgv_banner);
                viewHolder.ll_banner.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        jupAct(albums.get(0).getUrl());
                    }
                });
            }

        } else {
            viewHolder.topic_all_layout.setVisibility(View.VISIBLE);
            viewHolder.unsee_layout.setVisibility(View.GONE);
            viewHolder.ll_banner.setVisibility(View.GONE);
            if (topic.getUser() != null) {
                viewHolder.user_name.setText(topic.getUser().getNick() + "");
                glideUtils.Glidde_loadCropCircleImage(mContext, topic.getUser().getLogo(), viewHolder.user_icon);
                viewHolder.user_icon.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        Intent intent = new Intent(mContext, UserInfoOtherActivity.class);
                        intent.putExtra("user", topic.getUser());
                        mContext.startActivity(intent);
                    }
                });
                if(null!=topic.getUser().getUserAuth()){
                    if ("-1".equals(topic.getUser().getUserAuth().getType())){
                        viewHolder.isvip.setVisibility(View.GONE);
                    }
                    if("0".equals(topic.getUser().getUserAuth().getType())){
                        viewHolder.isvip.setVisibility(View.VISIBLE);
                        viewHolder.isvip.setImageResource(R.drawable.v_huan);
                    }else if("1".equals(topic.getUser().getUserAuth().getType())){
                        viewHolder.isvip.setVisibility(View.VISIBLE);
                        viewHolder.isvip.setImageResource(R.drawable.v_lan);
                    }
                }else{
                    viewHolder.isvip.setVisibility(View.GONE);
                }
            }
            viewHolder.topic_time.setText(DateUtils.getTimestampStringBB(Long.valueOf(topic.getCreateAt())));
            /*****************内容*****************/
            viewHolder.topic_content.setVisibility(View.VISIBLE);
            if (TextUtils.isEmpty(topic.getContent())) {
                viewHolder.topic_content.setVisibility(View.GONE);
            }
            viewHolder.topic_content.setText(topic.getContent(),new Intent(mContext, GzWebViewActivity.class));
            viewHolder.imgv_zan.setImageResource(R.drawable.bb_zan_selector);
            viewHolder.ll_zan.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    likeAnimation(viewHolder,topic,position);
                }
            });
            viewHolder.ll_comment.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(mContext, GzTopicDetailActivity.class);
                    intent.putExtra("topicId", datas.get(position).getPostsId());
                    intent.putExtra("isShowCommentDialog",true);
                    mContext.startActivity(intent);
                    ((Activity)mContext).overridePendingTransition(R.anim.slide_in_from_right,
                            R.anim.slide_out_to_left);
                }
            });

            if ("1".equals(topic.getLiked())) {
                viewHolder.ll_zan.setSelected(true);
            } else {
                viewHolder.ll_zan.setSelected(false);
            }
            if ("1".equals(topic.getNice())) {
                viewHolder.imgv_digest.setVisibility(View.VISIBLE);
            } else {
                viewHolder.imgv_digest.setVisibility(View.GONE);
            }
            if(Integer.parseInt(topic.getLikes())>0){
                viewHolder.tv_zan_count.setText(topic.getLikes());
            }else{
                viewHolder.tv_zan_count.setText("赞");
            }
            if(Integer.parseInt(topic.getReplys())>0){
                viewHolder.tv_comment_count.setText(topic.getReplys());
            }else{
                viewHolder.tv_comment_count.setText("评论");
            }

            /**************** 红包 *********************/
            if (!TextUtils.isEmpty(topic.getRedId())) {
                viewHolder.red_icon.setVisibility(View.VISIBLE);
            } else {
                viewHolder.red_icon.setVisibility(View.GONE);
            }

            /**************** 语音 *********************/
            ArrayList<PostsAlbum> audios = topic.getAudios();
            if (audios != null && audios.size() > 0) {
                viewHolder.ll_voice.setVisibility(View.VISIBLE);
                playVoice(viewHolder, audios.get(0).getUrl(), audios.get(0)
                        .getThumbnail(), topic.getPostsId());
            }else{
                viewHolder.ll_voice.setVisibility(View.GONE);
            }


            /*****************图片*****************/
            final ArrayList<PostsAlbum> albums = topic.getAlbums();
            ViewGroup.LayoutParams params = viewHolder.unableScrollGridView.getLayoutParams();
            params.width = ViewGroup.LayoutParams.WRAP_CONTENT;
            params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
            viewHolder.unableScrollGridView.setLayoutParams(params);
            if (albums != null && albums.size() > 0) {
                viewHolder.unableScrollGridView.setVisibility(View.VISIBLE);
                BBImageShowAdapter imageAdapter = new BBImageShowAdapter(mContext, position);
                imageAdapter.setPostsAlbums(albums);
                viewHolder.unableScrollGridView.setAdapter(imageAdapter);
//                ViewGroup.LayoutParams params = viewHolder.unableScrollGridView.getLayoutParams();
//                params.width = ViewGroup.LayoutParams.WRAP_CONTENT;
//                params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
//                viewHolder.unableScrollGridView.setLayoutParams(params);
                if (topic.getCategory().equals("1")) {//如果是视频帖子
                    imageAdapter.setItemW(DensityUtils.getScreenW((Activity) mContext));
                    imageAdapter.setItemH(DensityUtils.dip2px(mContext, 200));
                    imageAdapter.setShowPlay(true,topic.getVideo());
                    viewHolder.unableScrollGridView.setNumColumns(1);
                } else if (1 == imageAdapter.getCount()) {
                    int ww = (int) mContext.getResources().getDimension(
                            R.dimen.size_34);
                    int w = albums.get(0).getWidth();
                    int h = albums.get(0).getHeight();
                    int tmpw;
                    int tmph;
                    //如果是超长图，最长设置200dp
                    if (h > DensityUtils.dip2px(mContext, maxHeight) && h>w) {
                        tmph = DensityUtils.dip2px(mContext, maxHeight);
                        imageAdapter.setItemW(w * tmph / h);
                        imageAdapter.setItemH(tmph);
                        if (imageAdapter.getItemH() / imageAdapter.getItemW() > 2) { //如果宽度太小（图太长，则宽度设为高的1/2，等比例裁图显示）
                            imageAdapter.setItemW(imageAdapter.getItemH() / 2);
                        }
                        if(imageAdapter.getItemW()>DensityUtils.getScreenW((Activity) mContext) - ww){ //如宽超出屏幕
                            tmpw = DensityUtils.getScreenW((Activity) mContext) - ww;
                            imageAdapter.setItemW(tmpw);
                            imageAdapter.setItemH(imageAdapter.getItemH() * tmpw / imageAdapter.getItemW());
                        }
                    } else if (w > DensityUtils.getScreenW((Activity) mContext) - ww) {//如果是超宽图，最宽设置为屏幕宽
                        tmpw = DensityUtils.getScreenW((Activity) mContext) - ww;
                        imageAdapter.setItemW(tmpw);
                        imageAdapter.setItemH(h * tmpw / w);
                        if(imageAdapter.getItemH()>DensityUtils.dip2px(mContext, maxHeight)){
                            tmph = DensityUtils.dip2px(mContext, maxHeight);
                            imageAdapter.setItemW(imageAdapter.getItemW()*tmph/imageAdapter.getItemH());
                            imageAdapter.setItemH(tmph);
                        }
                    } else if (w == 0 && h == 0) {
                        imageAdapter.setItemW(DensityUtils.dip2px(mContext, 100));
                        imageAdapter.setItemH(DensityUtils.dip2px(mContext, 100));
                    } else if (w < 250 && h < 250) {
                        imageAdapter.setItemW(w * 3);
                        imageAdapter.setItemH(h * 3);
                    } else {
                        imageAdapter.setItemW(w);
                        imageAdapter.setItemH(h);
                    }
                    ViewGroup.LayoutParams params2 = viewHolder.unableScrollGridView.getLayoutParams();
                    params2.width = imageAdapter.getItemW();
                    params2.height = imageAdapter.getItemH();
                    viewHolder.unableScrollGridView.setLayoutParams(params2);
                    viewHolder.unableScrollGridView.setNumColumns(1);
                } else if (imageAdapter.getCount()>1) {
                    int ww = (int) mContext.getResources().getDimension(
                            R.dimen.size_44);
                    viewHolder.unableScrollGridView.setNumColumns(3);
                    imageAdapter.setItemW((DensityUtils
                            .getScreenW((Activity) mContext) - ww) / 3);
                }
                imageAdapter.notifyDataSetChanged();

            } else {
                viewHolder.unableScrollGridView.setVisibility(View.GONE);
            }
            viewHolder.unableScrollGridView
                    .setOnTouchBlankPositionListener(new UnableScrollGridView.OnTouchBlankPositionListener() {

                        @Override
                        public boolean onTouchBlankPosition() {
                            jumpTopicDetailActivity(position);
                            return true;
                        }
                    });
            viewHolder.topic_content.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0) {
                    jumpTopicDetailActivity(position);
                }
            });
        }
    }


    //获取数据的数量
    @Override
    public int getItemCount() {
        if(datas==null)return 0;
        return datas.size();
    }

    public List<Topic> getDatas() {
        return datas;
    }

    public void setDatas(List<Topic> datas) {
        this.datas = datas;
    }


    /**
     * 播放语音
     *
     * @param
     */
    private void playVoice(final BBAdapter.ViewHolder viewHolder, final String urlPro,
                           final String thumbnail, final String postsId) {
        int lenght = 1;
        try {
            lenght = Integer
                    .parseInt(urlPro.substring(urlPro.lastIndexOf("/") + 1));
        } catch (NumberFormatException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        // 设置语音消息的背景
        ViewGroup.LayoutParams para = viewHolder.iv_voice_bg.getLayoutParams();
        Resources r = mContext.getResources();
        int min = (int) r.getDimension(R.dimen.size_50);
        int max = (int) r.getDimension(R.dimen.size_150);
        int plus = (max - min) * lenght / 60;
        para.width = min + plus;
        viewHolder.iv_voice_bg.setLayoutParams(para);

        viewHolder.tv_length.setText(lenght + "\"");

        if (mediaPlayerUtil.isPlaying() && playMsgId.equals(postsId)) {
            viewHolder.iv_voice
                    .setImageResource(R.drawable.voice_to_play_topic_list);
            voiceAnimation = (AnimationDrawable) viewHolder.iv_voice
                    .getDrawable();
            voiceAnimation.start();
            voiceViewList.add(viewHolder.iv_voice);
        } else {
            // if(voiceAnimation!=null &&
            // voiceAnimation.isRunning())voiceAnimation.stop();
            viewHolder.iv_voice
                    .setImageResource(R.drawable.gz_topic_voice_playing_f3);
        }

        viewHolder.iv_voice_bg.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                if (mediaPlayerUtil.isPlaying()) {
                    if (voiceAnimation != null && voiceAnimation.isRunning())
                        voiceAnimation.stop();
                    // topicHolder.iv_voice.setImageResource(R.drawable.gz_topic_voice_playing_f3);
                    mediaPlayerUtil.stopPlayVoice();
                    for (int i = 0; i < voiceViewList.size(); i++) {
                        voiceViewList.get(i).setImageResource(
                                R.drawable.gz_topic_voice_playing_f3);
                    }
                    voiceViewList.clear();
                } else {
                    viewHolder.iv_voice.setVisibility(View.GONE);
                    viewHolder.iv_voice_bg.clearAnimation();
                    viewHolder.iv_voice_bg.setAnimation(set);
                    set.start();

                    mediaPlayerUtil.playVoice(thumbnail);
                    playMsgId = postsId;
//                    isPlaying = true;
                    // voiceAnimation = (AnimationDrawable)
                    // topicHolder.iv_voice.getDrawable();
                    // voiceAnimation.start();
                    // voiceViewList.add(topicHolder.iv_voice);
                    mediaPlayerUtil.getMediaPlayer().setOnCompletionListener(
                            new MediaPlayer.OnCompletionListener() {

                                @Override
                                public void onCompletion(MediaPlayer mp) {
                                    // TODO Auto-generated method stub
                                    playMsgId = "";
//                                    isPlaying = false;
                                    try {
                                        voiceAnimation.stop();
                                    } catch (Exception e) {
                                        // TODO Auto-generated catch block
                                        e.printStackTrace();
                                    }
                                    mediaPlayerUtil.stopPlayVoice();
                                    viewHolder.iv_voice
                                            .setImageResource(R.drawable.gz_topic_voice_playing_f3);
                                }
                            });

                    mediaPlayerUtil.getMediaPlayer().setOnPreparedListener(
                            new MediaPlayer.OnPreparedListener() {

                                @Override
                                public void onPrepared(MediaPlayer mp) {
                                    // TODO Auto-generated method stub
                                    viewHolder.iv_voice
                                            .setVisibility(View.VISIBLE);
                                    viewHolder.iv_voice
                                            .setImageResource(R.drawable.voice_to_play_topic_list);
                                    voiceAnimation = (AnimationDrawable) viewHolder.iv_voice
                                            .getDrawable();
                                    viewHolder.iv_voice.clearAnimation();
                                    voiceAnimation.start();
                                    voiceViewList.add(viewHolder.iv_voice);

                                    viewHolder.iv_voice_bg.clearAnimation();
                                }
                            });
                }

            }
        });
    }

    private void likeAnimation(final BBAdapter.ViewHolder viewHolder , Topic topic, final int position){
        if ("0".equals(topic.getLiked())) {
            viewHolder.imgv_zan.setImageResource(R.drawable.good2);
            viewHolder.imgv_zan.startAnimation(scaleAnimation);
            viewHolder.imgv_star1.setVisibility(View.GONE);
            viewHolder.imgv_star2.setVisibility(View.GONE);
            viewHolder.imgv_star1.startAnimation(starSet);
            viewHolder.imgv_star2.startAnimation(starSet);
            scaleAnimation.setAnimationListener(new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {

                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    viewHolder.imgv_star1.setVisibility(View.GONE);
                    viewHolder.imgv_star2.setVisibility(View.GONE);
                    if (likeClickListener != null) {
                        likeClickListener.like(position);
                    }
                }

                @Override
                public void onAnimationRepeat(Animation animation) {

                }
            });
        }else{
            if (likeClickListener != null) {
                likeClickListener.like(position);
            }
        }
    }

    public MediaPlayerUtil getMediaPlayerUtil() {
        return mediaPlayerUtil;
    }

    public void setMediaPlayerUtil(MediaPlayerUtil mediaPlayerUtil) {
        this.mediaPlayerUtil = mediaPlayerUtil;
    }

    public interface LikeClickListener {
        void like(int position);
    }

    public LikeClickListener getLikeClickListener() {
        return likeClickListener;
    }

    public void setLikeClickListener(LikeClickListener likeClickListener) {
        this.likeClickListener = likeClickListener;
    }


    public interface cancleCollectionPostListener {
        void cancleCollectionPost(int position);
    }

    public cancleCollectionPostListener getCollectionPostListener() {
        return collectionPostListener;
    }

    public void setCancleCollectionPostListener(cancleCollectionPostListener collectionPostListener) {
        this.collectionPostListener = collectionPostListener;
    }

    public void jumpTopicDetailActivity(int position){
        Intent intent = new Intent(mContext, GzTopicDetailActivity.class);
        intent.putExtra("topicId", datas.get(position).getPostsId());
        intent.putExtra("redState", datas.get(position).getRedState());
        mContext.startActivity(intent);
        ((Activity)mContext).overridePendingTransition(R.anim.slide_in_from_right,
                R.anim.slide_out_to_left);
    }

    private void jupAct(String protocol) {
        try {
            String msg = protocol.substring(protocol.indexOf("//")+2);
            String key = msg.substring(0,msg.indexOf("/"));
            String value = msg.substring(msg.indexOf("/")+1);

            if(key.equals(BBConstant.BANNER_JUMP_TYPE_URL)){
                Intent i = new Intent(mContext,GzWebViewActivity.class);
                i.putExtra("url", value);
//                i.putExtra("title", banner.getTitle());
                mContext.startActivity(i);
            }else if(key.equals(BBConstant.BANNER_JUMP_TYPE_BB)){
                Intent intent = new Intent(mContext,GzTopicDetailActivity.class);
                intent.putExtra("topicId", value);
                mContext.startActivity(intent);

            }else if(protocol.contains(BBConstant.BANNER_JUMP_TYPE_TAOBAO1) || protocol.contains(BBConstant.BANNER_JUMP_TYPE_TAOBAO2)){
                //跳转商城
                HashMap<String, Object> hashMap = new HashMap<String, Object>();
                hashMap.put("event", BroadCastEvent.JUMPTAOBAO);
                EventBus.getEventBus(BroadCastEvent.EVENTBUS_COMMON,
                        ThreadEnforcer.MAIN).post(hashMap);

            }else if(key.equals( BBConstant.BANNER_JUMP_TYPE_GROUP)){
                Intent intent=new Intent(mContext, GroupDetailsActivity.class);
                intent.putExtra("groupid",value);
                intent.putExtra("groupname","群组");
                mContext.startActivity(intent);
            }
        } catch (Exception e) {
            // TODO: handle exception
        }
    }

    //自定义的ViewHolder，持有每个Item的的所有界面元素
    public static class ViewHolder extends RViewHolder {
        private EmojiconTextView1 topic_content;
        private TextView topic_time,user_name,topic_unsee_del;
        private TextView tv_comment_count,tv_zan_count;
        private ImageView user_icon,red_icon,imgv_digest,isvip,imgv_zan,imgv_star1,imgv_star2,imgv_banner;
        private UnableScrollGridView unableScrollGridView;
        //语音
        ImageView iv_voice, iv_voice_bg;
        RelativeLayout ll_voice;
        TextView tv_length;
        FrameLayout topic_all_layout;
        //
        LinearLayout ll_zan,ll_comment,unsee_layout,ll_banner;

        public ViewHolder(View view, MyItemClickListener mListener, MyItemLongClickListener mLongClickListener){
            super(view,mListener,mLongClickListener);
            topic_content = (EmojiconTextView1) view.findViewById(R.id.topic_content);
            topic_time = (TextView) view.findViewById(R.id.topic_time);
            user_name = (TextView) view.findViewById(R.id.user_name);
            tv_zan_count = (TextView) view.findViewById(R.id.tv_zan_count);
            tv_comment_count = (TextView) view.findViewById(R.id.tv_comment_count);
            user_icon = (ImageView) view.findViewById(R.id.user_icon);
            red_icon = (ImageView) view.findViewById(R.id.red_icon);
            imgv_digest = (ImageView) view.findViewById(R.id.imgv_digest);
            unableScrollGridView = (UnableScrollGridView) view.findViewById(R.id.unableScrollGridView);
            iv_voice = (ImageView) view.findViewById(R.id.iv_voice);
            iv_voice_bg = (ImageView) view.findViewById(R.id.iv_voice_bg);
            ll_voice = (RelativeLayout) view.findViewById(R.id.ll_voice);
            tv_length = (TextView) view.findViewById(R.id.tv_length);
            ll_zan = (LinearLayout) view.findViewById(R.id.ll_zan);
            imgv_zan = (ImageView) view.findViewById(R.id.imgv_zan);
            imgv_star1 = (ImageView) view.findViewById(R.id.imgv_star1);
            imgv_star2 = (ImageView) view.findViewById(R.id.imgv_star2);
            ll_comment = (LinearLayout) view.findViewById(R.id.ll_comment);
            unsee_layout = (LinearLayout) view.findViewById(R.id.unsee_layout);
            topic_all_layout = (FrameLayout) view.findViewById(R.id.topic_all_layout);
            topic_unsee_del= (TextView) view.findViewById(R.id.topic_unsee_del);
            isvip= (ImageView) view.findViewById(R.id.isvip);

            ll_banner = (LinearLayout) view.findViewById(R.id.ll_banner);
            imgv_banner = (ImageView) view.findViewById(R.id.imgv_banner);

        }
    }

}
